/*
 * @Author       : 魏威 <1209562577@qq.com>
 * @Date         : 2022-03-28 16:47 周1
 * @Description  :
 */

import { useHttp } from "api";
import { useEffect } from "react";
import { User } from "types";
import { cleanObject } from "utils";
import { useAsync } from "./useAsync";

export const useUsers = (param?: Partial<User>) => {
  const client = useHttp();

  const { run, ...result } = useAsync<User[]>();

  useEffect(() => {
    run(client("users", { data: cleanObject(param || {}) }));
  }, [param]);

  return result;
};
